package main

import (
	"context"
	"fmt"
	_ "github.com/mbobakov/grpc-consul-resolver" // It's important  //负债均衡  必须引入 ！！！！！！！！！
	"go.uber.org/zap"
	"google.golang.org/grpc"
	protopb "service_base_shop/jwt_srv/proto"

)

func main()  {
	userConn, err := grpc.Dial(
		fmt.Sprintf("consul://%s:%d/%s", "192.168.101.170",8500,"jwt_srv"),
		grpc.WithInsecure(),
		grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy": "round_robin"}`),
		//grpc.WithChainUnaryInterceptor((otgrpc.OpenTracingClientInterceptor(opentracing.GlobalTracer()))), //修改源码 达到要求
	)
	if err != nil {
		zap.S().Fatal("user_srv链接失败")
	}
	c :=  protopb.NewJwtClient(userConn)
	//data,err1 := c.CreateToken(context.Background(),&protopb.CreateTokenReq{ID: 1,NickName: "aaa"})
	//data2,err12 := c.ParseToken(context.Background(),&protopb.ParseTokenReq{Token: data.Token})
	////time.Sleep(time.Second * 7)
	////data23,err123 := c.RefreshToken(context.Background(),&protopb.RefreshTokenReq{Token: data.Token})
	//
	//fmt.Println(err1,data.Token)
	//fmt.Println(data2,err12)
	data2,err12 := c.ReduceProduct(context.Background(),&protopb.ReduceProductReq{GoodsId: 284,Num: 3})
	fmt.Println(data2,err12)
}
